package thinkinjava4.ch12_exceptions;

class OnOffException1 extends Exception {
}

class OnOffException2 extends Exception {
}

public class OnOffSwitch {
    private static Switch sw = new Switch();

    public static void throwOtherException() {
        throw new RuntimeException();
    }

    public static void f() throws OnOffException1, OnOffException2 {
        throw new OnOffException1();
    }

    public static void main(String[] args) {
        try {
            sw.on();
            //假如这里抛出了异常off不会被执行
            throwOtherException();
            f();
            sw.off();
        } catch (OnOffException2 | OnOffException1 e) {
            System.out.println(e.getClass().getSimpleName());
            sw.off();
        }
    }
}
